<?php 

Class shakeController extends appController
{
	
	public function index()
	{
		$page=isset($_REQUEST['page'])?intval($_REQUEST['page']):1;
		$list=Model('shake')->lists($page);
	
		$this->assign('sql_list',$list['data']);
		$this->assign('list_page',$list['pagelink']);
		$this->assign('count',$list['count']);
		
		$this->display('index.html');
		
	}
	
	
	public function statistic()
	{
		
		$m = Model('shake');
		
		$list=$m->list_province();
		
		$total = $m->get_total();
		
		$this->assign('list',$list);
		
		$this->assign('total',$total);
		
		$this->display('statistic.html');
		
	}
	
	public function all()
	{
	
		$page=isset($_REQUEST['page'])?intval($_REQUEST['page']):1;
		$list=Model('shake')->all($page);
	
		$this->assign('sql_list',$list['data']);
		
		$this->assign('count',$list['count']);
	
		$this->display('index.html');
	
	}
	
	public function list_city()
	{
		
		$id = $_GET['id'];
		
		$list=Model('shake')->list_city($id);
	
		$this->assign('list',$list);
		
		$this->assign("type", "city");
		
		$this->display('statistic.html');
		
	}
	

	//导出活动列表
	function execlLevy()
	{
		$title = array("序号","微信昵称","姓名","电话","地址","分数","游戏次数","助力次数","提交时间");
		
		$where = " where  1=1 ";
		
		if($_GET['prize'])
		{
			$where.="  prize = ".$_GET['prize'] ;
		}
		else 
		{
			
		}
		
		$result = Model('shake')->get_levy_records($where);
		
		if($result)
		
		foreach ($result as $key => $value){
			
		/* 	switch($value['prize'])
			{
				case 1:
					$prize = "一等奖";
					break;
				case 2:
					$prize = "二等奖";
					break;
				case 3:
					$prize = "三等奖";
					break;
				case 4:
					$prize = "四等奖";
					break;
				case 5:
					$prize = "五等奖";
					break;
				default:
					$prize = " -- ";
			} */
			
			$_data[$key] = array($value['order'],$value['nickname']?$value['nickname']:"",$value['name']?$value['name']:"",$value['phone']?$value['phone']:"",$value['address']?$value['address']:"",$value['score']+$value['add_score']?$value['score']+$value['add_score']:"",$value['playnums']?$value['playnums']:"",$value['joinnums']?$value['joinnums']:"",date("Y - m -d",$value['addtime']));
		}
		exportData("活动列表",$title,$_data);
		
		exit;
	}
	
}